#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>

int main()
{
    pid_t pid;

    if((pid = fork())==-1)
    {
        perror("fork!");
        exit(1);
    }

    if(pid == 0)
    {
        sleep(10);
        exit(6);
    }else{
        int st;
        int ret = wait(&st);

        if(ret > 0 && (st & 0X7F)==0)
        {
            printf("子进程的退出码：%d\n",(st>>8)&0XFF);
        }else if(ret > 0){
            printf("错误退出码：%d\n",st&0X7F);
        }
    }

    return 0;
}
